package com.iexbuy.ihg.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.iexbuy.ihg.R;
import com.iexbuy.ihg.entity.CashTiXianListObject;
import com.iexbuy.ihg.utils.StringUtil;

import java.util.ArrayList;
import java.util.List;

;

public class CashTiXianHistoryListAdapter extends BaseAdapter {

	private List<CashTiXianListObject> datas = new ArrayList<CashTiXianListObject>();
	private Context context;

	public CashTiXianHistoryListAdapter(Context context, List<CashTiXianListObject> datas) {
		super();
		this.context = context;
		if (datas != null) this.datas = datas;
	}

	@Override
	public int getCount() {
		return datas.size();
	}

	@Override
	public Object getItem(int location) {
		return datas.get(location);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(R.layout.fragment_wede_cash_tixiang_list_item, null);
		}
		CashTiXianListObject vo = (CashTiXianListObject)datas.get(position);

		((TextView) convertView.findViewById(R.id.itemStatus)).setText(getStatusName(vo.getStatusName()));
		((TextView) convertView.findViewById(R.id.itemAount)).setText(vo.getDelta()+"元");
		((TextView) convertView.findViewById(R.id.itemTime)).setText(vo.getTime());

		return convertView;
	}
	
	private String getStatusName(String status) {
		String statusName = status;
		if (StringUtil.isEmpty(status)) {
			statusName = "金币变更";
		}
		return statusName;
	}
	
}
